package com.hdsx.restful.glzt.roadline.xzqh.service.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.apache.commons.beanutils.PropertyUtils;
import org.springframework.stereotype.Service;

import com.hdsx.ao.base.BaseOpearte;
import com.hdsx.restful.glzt.roadline.lxxx.bean.Line;
import com.hdsx.restful.glzt.roadline.lxxx.bean.LxAreaDetail;
import com.hdsx.restful.glzt.roadline.lxxx.bean.Xzqh;
import com.hdsx.restful.glzt.roadline.xzqh.mapper.XzqhMapper;
import com.hdsx.restful.glzt.roadline.xzqh.service.XzqhService;
import com.hdsx.restful.util.CheckEmpty;

@Service
public class XzqhServiceImpl extends BaseOpearte<Xzqh> implements XzqhService{
	public XzqhServiceImpl() {
		super("GIS_XZQH");
	}

	@Resource(name="xzqhMapper")
	private XzqhMapper mapper;
	
	@Override
	public List<Xzqh> queryList(Map<String, Object> map) {
		return mapper.selectList(map);
	}
	@Override
	public int queryCount(Map<String, Object> map) {
		return mapper.selectCount(map);
	}
	
	@Override
	public Line ldDetail(Line param) {
		Line line = new Line();
		if(!CheckEmpty.isEmptyString(param.getId())){
			Xzqh bean = mapper.selectById(param.getId());
			try {
				PropertyUtils.copyProperties(line, bean);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				line = null;
			}
		}else if(!CheckEmpty.isEmptyString(param.getLxdm())){
			Line detail = mapper.ldDetail(param);
			line.setLxdm(param.getLxdm());
			line.setQdzh(param.getQdzh());
			line.setZdzh(param.getZdzh());
			line.setXzqhbm(param.getXzqhbm());
			line.setSxxfx(param.getSxxfx());
			line.setLxmc(detail.getLxmc());
			line.setQdmc(detail.getQdmc());
			line.setZdmc(detail.getZdmc());
			line.setLc(detail.getLc());
		}
		return line;
	}
	
	@Override
	public List<LxAreaDetail> lxArea(Line param){
		return mapper.lxArea(param);
	}
	
	@Override
	public List<String> selectName(String name){
		return mapper.selectName(name);
	}
}
